package com.xy.manage.service.impl;


import java.util.List;
import java.util.Map;
import java.util.Date;
import com.xy.core.util.BeanUtil;
import com.xy.common.page.Pagination;
import com.xy.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xy.manage.dao.TsurveyoptionsDao;
import com.xy.manage.model.Tsurveyoptions;
import com.xy.manage.service.TsurveyoptionsService;

@Service
@Transactional
public class TsurveyoptionsServiceImpl extends BaseServiceImpl<Tsurveyoptions> implements
		TsurveyoptionsService {
	private TsurveyoptionsDao tsurveyoptionsDao;

	public TsurveyoptionsServiceImpl(TsurveyoptionsDao paramAppRoleDao) {
		super(paramAppRoleDao);
		this.tsurveyoptionsDao = paramAppRoleDao;
	}

	@Override
	public boolean checkExist(String paraName, String paraValue) {
		return tsurveyoptionsDao.checkExist("Tsurveyoptions", paraName, paraValue);
	}

	@Override
	public List<Tsurveyoptions> getTsurveyoptions(Map<String, Object> map) {
		return tsurveyoptionsDao.getTsurveyoptions(map);
	}
	@Override
	public Pagination getTsurveyoptionsByPage(Map<String, Object> map, int pageNo,
			int pageSize) {
		// TODO Auto-generated method stub
		return tsurveyoptionsDao.getTsurveyoptionsByPage(map, pageNo, pageSize);
	}
	 
   @Override
	public Tsurveyoptions save(Tsurveyoptions tsurveyoptions) {
	//	tsurveyoptions.setModtime(new Date());
		if(tsurveyoptions.getAnswerid()==null){
			//新增
        	return super.save(tsurveyoptions);
		}else{
			//更新
			Tsurveyoptions tsurveyoptions1=tsurveyoptionsDao.get(tsurveyoptions.getAnswerid());
			try {
				BeanUtil.copyNotNullProperties(tsurveyoptions1, tsurveyoptions);
			} catch (Exception e) {
				e.printStackTrace();
			}  
			return super.save(tsurveyoptions1);
		}
	}
}